<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加栏目</title>
    <link rel="stylesheet" href="__COMMON__/dtree/dtree.css">
    <link rel="stylesheet" href="__COMMON__/dtree/font/dtreefont.css">
    <link rel="stylesheet" href="__COMMON__/css/simple.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <style>
        .margin {margin: 10px;}
        .alert-dismissable, .alert-dismissible {padding-right: 35px;}
        .alert {padding: 15px;margin-bottom: 17px;border: 1px solid transparent;border-radius: 3px;}
        .bg-info {background-color: #d9edf7;}
        .img-list {width: 80%;height: 140px;margin-left: 105px;}
        .img-list .img-one {width: 120px;height: 120px;padding: 10px;float: left;}
        .img-list .img-one a {display: block;text-align: center;border: 1px solid #e2e2e2;}
        .del-btn {margin-top: 10px;cursor: pointer;color: #fff;text-align: center;background-color: #d62c1a;border-color: #cd2a19;}
        .layui-form-radio>i:hover, .layui-form-radioed>i{color: #1E9FFF;}
    </style>
</head>
<body>

<form class="layui-form" action="" style="padding: 10px">
    <div class="layui-form-item">
        <label class="layui-form-label"><em style="color: red">*</em> 类型</label>
        <div class="layui-input-block">
            {foreach name="channel_type" item="vo" key="key"}
            <input type="radio" name="type" lay-filter="type" value="{$key}" title="{$vo}" {if $key eq 'list'}checked{/if}>
            {/foreach}
            <div class="margin" style="margin-left:0;">
                <div class="alert alert-dismissable bg-info">
                    <strong>频道封面</strong>: 频道封面本身不允许添加文章<br>
                    <strong>列表类型</strong>: 列表类型下可以发布文章<br>
                    <strong>外部链接</strong>: 外部链接类型下不可以发布文章<br>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><em style="color: red">*</em> 模型</label>
        <div class="layui-input-block">
            <select class="layui-input" name="model_id" id="model_id" lay-filter="model_id">
                {foreach name="model" item="vo" key="key"}
                <option value="{$key}">{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><em style="color: red">*</em> 上级栏目</label>
        <div class="layui-input-block">
            <ul id="selTree1" class="dtree" data-id="0"></ul>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><em style="color: red">*</em> 名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" required lay-verify="required" autocomplete="off" class="layui-input" id="name">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline" style="width: 500px">
            <input type="text" name="image" autocomplete="off" class="layui-input" id="image">
        </div>
        <div class="layui-btn-group" style="margin-top: 5px">
            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="upload">
                <i class="layui-icon">&#xe67c;</i> 上传
            </button>
            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="showImgDialog()">
                <i class="layui-icon">&#xe610;</i> 选择
            </button>
        </div>
    </div>
    <div class="img-list" style="display: none" id="img-list">

    </div>
    <script id="img-tpl" type="text/html">
        <div class="img-one">
            <a href="{{ d.url }}" target="_blank">
                <img src="{{ d.url }}" width="90px" height="90px"/>
            </a>
            <div class="del-btn" onclick="removeImg()">
                <i class="layui-icon layui-icon-delete"></i>
            </div>
        </div>
    </script>

    <div class="layui-form-item">
        <label class="layui-form-label">SEO标题</label>
        <div class="layui-input-block">
            <input type="text" name="seo_title" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">关键字</label>
        <div class="layui-input-block">
            <input type="text" name="keywords" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <textarea class="layui-input" name="description" style="height: 100px"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><em style="color: red">*</em> 自定义URL名称</label>
        <div class="layui-input-block">
            <input type="text" name="diyname" required lay-verify="required" autocomplete="off" class="layui-input" id="diyname">
        </div>
    </div>

    <div class="layui-form-item" id="outlink-div" style="display: none">
        <label class="layui-form-label"><em style="color: red">*</em> 外部链接</label>
        <div class="layui-input-block">
            <input type="url" name="outlink" autocomplete="off" class="layui-input" id="outlink" placeholder="http://">
        </div>
    </div>

    <div class="layui-form-item" id="channel-tpl-div" style="display: none">
        <label class="layui-form-label"><em style="color: red">*</em> 栏目页模板</label>
        <div class="layui-input-block">
            <input type="text" name="channel_tpl" autocomplete="off" class="layui-input" id="channel_tpl" placeholder="必须以channel_开头">
        </div>
    </div>

    <div id="list-tpl-div">
        <div class="layui-form-item">
            <label class="layui-form-label"><em style="color: red">*</em> 列表页模板</label>
            <div class="layui-input-block">
                <input type="text" name="list_tpl" autocomplete="off" class="layui-input" id="list_tpl" placeholder="必须以list_开头">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><em style="color: red">*</em> 详情页模板</label>
            <div class="layui-input-block">
                <input type="text" name="show_tpl" autocomplete="off" class="layui-input" id="show_tpl" placeholder="必须以show_开头">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">分页大小</label>
            <div class="layui-input-block">
                <input type="number" name="pagesize" required lay-verify="required" autocomplete="off" class="layui-input" value="10">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="正常" checked>
            <input type="radio" name="status" value="2" title="隐藏">
        </div>
    </div>

    <div class="layui-form-item" style="margin-top: 40px">
        <div class="layui-input-block">
            <button type="button" class="am-btn am-btn-success am-btn-sm" lay-submit lay-filter="subForm">立即提交</button>
            <button type="reset" class="am-btn am-btn-default am-btn-sm" >重置</button>
        </div>
    </div>
</form>

<script src="__COMMON__/jquery.min.js"></script>
<script src="__STATIC__/layui/layui.js"></script>
<script>
    var channelTpl = {$model_tpl|raw};
    var data = [{$channel_tree|raw}];
    var pid = '{$pid}';
    var acceptMime = '{$img["acceptMime"]}';
    var exts = '{$img["ext"]}';
    var uploadUrl = '{:url("attachment/upload")}';
    var showPicUrl = '{:url("attachment/show")}';
    var getPinyinUrl = '{:url("modelx/getPinyin")}';
    var optUrl = '{:url("channel/add")}';
    var hasPic = '';
</script>
<script src="__ADMIN__/js/channel/channel.js"></script>
</body>
</html>